var Material = Class.extend({
	init: function(context, shader, texture) {
		this.shader = shader;
		this.texture = texture;
	},

	// Set this once for the camera
	setModelViewProjMatrix: function(modelViewProjMatrix) {
		this.modelViewProjMatrix = modelViewProjMatrix;
	},
	

	bindBuffers: function(context, vertexBuffer, texCoordBuffer) {
		var gl = context.renderer.gl;
		var program = this.shader.shaderProgram;
        gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
        gl.vertexAttribPointer(program.vertexPositionAttribute, vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
		
		if (texCoordBuffer) {
			gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
			gl.vertexAttribPointer(program.textureCoordAttribute, texCoordBuffer.itemSize, gl.FLOAT, false, 0, 0);
		}
	},

	applyUniforms: function(context) {
		var gl = context.renderer.gl;
        this.shader._setModelViewProjMatrix(gl, this.modelViewProjMatrix);
		if (this.texture) {
			this.shader._setTexture(gl, this.texture);
		}
	},
	
}); 
